<template>
	<view class='demand'>
		<view class="dem_title">
			学生报道信息
		</view>
		<view class="main_view">
			<u-form :model="form" class="form_style">
				<u-form-item label-width="160" label="姓名"><u-input v-model="form.name"  :placeholder="nameplaceholder" /></u-form-item>
				<u-form-item label-width="160" label="学号"><u-input v-model="form.studentId" :placeholder="studentIdplaceholder" /></u-form-item>
				<u-form-item label-width="160" label="年龄">
					<u-input v-model="form.age" :placeholder="ageplaceholder" type="select" :border="true" @click="ageInfoListshow = true"/>
				</u-form-item>
				<u-form-item label-width="160" label="就读高中"><u-input v-model="form.highSchool"  :placeholder="highSchoolplaceholder"/></u-form-item>
				<u-form-item label-width="160" label="手机号码"><u-input v-model="form.telephone"  :placeholder="telephoneplaceholder"/></u-form-item>
				<u-form-item label-width="160" label="高考成绩"><u-input v-model="form.achievement"  :placeholder="achievementplaceholder"/></u-form-item>
				<u-form-item label-width="160" label="身份证号"><u-input v-model="form.idCard"  :placeholder="idCardplaceholder"/></u-form-item>
				<u-form-item label-width="160" label="准考证号"><u-input v-model="form.candidateId"  :placeholder="candidateIdplaceholder"/></u-form-item>
				<u-form-item label-width="120" label="性别">
					<u-input v-model="form.sex" :placeholder="sexplaceholder" type="select" :border="true" @click="sexInfoListshow = true"/>
				</u-form-item>
				<u-form-item label-width="120" label="籍贯">
					<u-input v-model="form.province" :placeholder="provinceplaceholder" type="select" :border="true" @click="provinceListshow = true"/>
				</u-form-item>
				<u-form-item label-width="160"label="详细地址"><u-input v-model="form.address"  :placeholder="addressplaceholder"/></u-form-item>
				<u-form-item label-width="120" label="学院">
					<u-input v-model="form.facultyName"  :placeholder="facultyNameplaceholder" type="select" :border="true" @click="specialtyNameListshow = true"/>
				</u-form-item>
				<u-form-item label-width="120" label="专业">
					<u-input v-model="form.discipline"  :placeholder="disciplineplaceholder" type="select" :border="true" @click="specialtyNameListshow = true"/>
				</u-form-item>
				<u-form-item label-width="120" label="班级">
					<u-input v-model="form.className"  :placeholder="classNameplaceholder" type="select" :border="true" @click="specialtyNameListshow = true"/>
				</u-form-item>
				<u-form-item label-width="120" label="政治面貌">
					<u-input v-model="form.political"  :placeholder="politicalplaceholder" type="select" :border="true" @click="reportInfoListshow = true"/>
				</u-form-item>
				<u-form-item label-width="160" label="父亲姓名"><u-input v-model="form.fname"  :placeholder="fnameplaceholder"/></u-form-item>
				<u-form-item label-width="180" label="父亲联系方式"><u-input v-model="form.ftelephone"  :placeholder="ftelephoneplaceholder"/></u-form-item>
				<u-form-item label-width="160" label="母亲姓名"><u-input v-model="form.mname"  :placeholder="mnameplaceholder"/></u-form-item>
				<u-form-item label-width="180" label="母亲联系方式"><u-input v-model="form.mtelephone"  :placeholder="mtelephoneplaceholder"/></u-form-item>
			</u-form>
			<u-button :ripple="true" type="primary" @click="formsubmit()">确认报道</u-button>
			<u-select v-model="specialtyNameListshow" mode="mutil-column-auto" :list="specialtyNameList" @confirm="confirm1"></u-select>
			<u-select v-model="reportInfoListshow" mode="mutil-column-auto" :list="reportInfoList" @confirm="confirm2"></u-select>
			<u-select v-model="sexInfoListshow" mode="mutil-column-auto" :list="sexInfoList" @confirm="confirm3"></u-select>
			<u-select v-model="provinceListshow" mode="mutil-column-auto" :list="provinceList" @confirm="confirm4"></u-select>
			<u-select v-model="ageInfoListshow" mode="mutil-column-auto" :list="ageInfoList" @confirm="confirm5"></u-select>
		</view>
	</view>
</template>

<script>
	export default {
	props: {},
	data() {
		return {
			form:{
				"achievement": "",//高考成绩
				  "address": "",//详细地址
				  "age": '',//年龄
				  "candidateId": "",//高考准考证号
				  "className": "",//所在班级
				  "discipline": "",//就读专业
				  "facultyName": "",//所在学院
				  "fname": "",//父亲姓名
				  "ftelephone": "",//父亲联系方式
				  "highSchool": "",//就读高中
				  "idCard": "",//身份证号码
				  "mname": "",//母亲姓名
				  "mtelephone": "",//母亲联系方式
				  "name": "",//姓名
				  "political": "",//政治面貌
				  "province": "",//省份
				  "sex": "",//性别
				  "studentId": '',//学号
				  "telephone": ''//手机号码
			},
			nameplaceholder:'请输入姓名',
			studentIdplaceholder:'请输入学号',
			ageplaceholder:'请输入年龄',
			highSchoolplaceholder:'请输入就读高中',
			telephoneplaceholder:'请输入手机号码',
			achievementplaceholder:'请输入高考成绩',
			idCardplaceholder:'请输入身份证号',
			candidateIdplaceholder:'请输入准考证号',
			sexplaceholder:'请选择性别',
			provinceplaceholder:'请选择籍贯',
			addressplaceholder:'请输入详细地址',
			facultyNameplaceholder:'请选择学院',
			disciplineplaceholder:'请选择专业',
			classNameplaceholder:'请选择班级',
			politicalplaceholder:'请选择政治面貌',
			fnameplaceholder:'请输入父亲姓名',
			ftelephoneplaceholder:'请输入父亲联系方式',
			mnameplaceholder:'请输入母亲姓名',
			mtelephoneplaceholder:'请输入母亲联系方式',
			specialtyNameList:[
				{value:1,label:'信息院',children:[{value:11,label:'物联网工程',children:[{value:111,label:'物联网工程21-1'},{value:112,label:'物联网工程21-2'}]},{value:12,label:'计算机科学与技术',children:[{value:121,label:'计算机21-1'},{value:122,label:'计算机21-2'}]},{value:13,label:'网络工程',children:[{value:131,label:'网络工程21-1'},{value:132,label:'网络工程21-2'}]},{value:14,label:'应用统计'},{value:15,label:'软件工程'}]},
				{value:2,label:'水建院',children:[{value:21,label:'专业1'},{value:22,label:'专业2'},{value:23,label:'专业3'},{value:24,label:'专业4'},{value:25,label:'专业5'}]},
				{value:3,label:'人文院',children:[{value:31,label:'专业1'},{value:32,label:'专业2'},{value:33,label:'专业3'},{value:34,label:'专业4'},{value:35,label:'专业5'}]},
				{value:4,label:'动科院',children:[{value:41,label:'专业1'},{value:42,label:'专业2'},{value:43,label:'专业3'},{value:44,label:'专业4'},{value:45,label:'专业5'}]}
			],
			specialtyNameListshow:false,
			reportInfoList:[
				{value:1,label:'党员'},{value:2,label:'团员'},{value:3,label:'群众'},{value:4,label:'其他'}
			],
			reportInfoListshow:false,
			sexInfoList:[
				{value:1,label:'男'},{value:2,label:'女'}
			],
			ageInfoList:[
				{value:15,label:15},{value:16,label:16},{value:17,label:17},{value:18,label:18},{value:19,label:19},{value:20,label:20},
				{value:21,label:21},{value:22,label:22},{value:23,label:23},{value:24,label:24},{value:25,label:25},{value:26,label:26},
				{value:27,label:27},{value:28,label:28},{value:29,label:29},{value:30,label:30},{value:31,label:31},{value:32,label:32},
				{value:33,label:33},{value:34,label:34},{value:35,label:35},{value:36,label:36},{value:37,label:37},{value:38,label:38},
			],
			sexInfoListshow:false,
			ageInfoListshow:false,
			provinceList:[
				{value:1,label:'河南',children:[
					{value:9999,label:'',children:[{value:9998,label:''}]},
					{value:11,label:'洛阳',children:[{value:9989,label:''},{value:111,label:'洛龙区'},{value:112,label:'老城区'}]},
					{value:12,label:'新乡',children:[{value:121,label:'一区'},{value:122,label:'八区区'}]},
					{value:13,label:'南阳',children:[{value:131,label:'四区区'},{value:132,label:'三区区'}]},
					{value:14,label:'平顶山',children:[{value:141,label:'五区区'},{value:142,label:'七区区'}]},
					]},
				{value:2,label:'新疆',children:[
					{value:9997,label:'',children:[{value:9996,label:''}]},
					{value:21,label:'乌鲁木齐',children:[{value:211,label:'天山区'},{value:212,label:'新区'}]}]},
				{value:3,label:'河北',children:[
					{value:31,label:'石家庄',children:[{value:311,label:'一区'},{value:312,label:'二区'}]}]},
				{value:4,label:'甘肃',children:[
					{value:41,label:'兰州',children:[{value:411,label:'一区'},{value:412,label:'二区'}]}]}
			],
			provinceListshow:false,
		}
	},
	// check:function(e){
	// 	var regNum =new RegExp('[0-9]','g')
	// 	var rsNum=regNum.execScript(e.detail.value)
	// 	if(rsNum){
	// 		uni.showToast({
	// 			title:'学号请输入数字'
	// 		})
	// 	}
	// },
	onLoad() {
		
	},
	methods: {
	confirm1(e) {
		console.log(e);
		this.form.facultyName=e[0].label
		this.form.discipline=e[1].label
		this.form.className=e[2].label
	},
	confirm2(e) {
		// console.log(e);
		this.form.political=e[0].label
	},
	confirm3(e) {
		// console.log(e);
		this.form.sex=e[0].label
	},
	confirm4(e) {
		// console.log(e);
		var str=e[0].label+e[1].label+e[2].label
		this.form.province=str
	},
	confirm5(e) {
		// console.log(e);
		var str=e[0].label
		this.form.age=str
	},
	regNum(value){
		return /^[0-9]/.test(value)
	},
	formsubmit(){
		var _this=this
		console.log('正则：')
		console.log(_this.regNum(123))
		if(_this.form.idCard==''){
			uni.showToast({
				title:'身份证号不能为空',
				icon:"none",
			})
		}else if(_this.form.studentId==''){
			uni.showToast({
				title:'学号不能为空',
				icon:"none",
			})
		}else if(_this.form.name==''){
			uni.showToast({
				title:'姓名不能为空',
				icon:"none",
			})
		}else{
			uni.request({
				url:'http://taruinfo.work:8088/newborn/inserts',
				data:_this.form,
				method:'POST',
				success:function(res){
					console.log('调用新生报到接口成功：')
					if(res.data.code ==200){
						uni.showToast({
						    title: '报道成功',
							icon:"success",
						    duration: 2000
						})
						setTimeout(function() {
							uni.reLaunch({
								url: '../index/index',
							});
						},1000);
					}else{
						console.log(res.data.message)
						uni.showToast({
								title:res.data.message,
								icon:"none",
								duration: 2000
						});
					}
				}
			})
		}
		
	},
	//向新生表中插入数据
	// requestNewBorn(data2){
	// 	var data=data2
	// 	uni.request({
	// 		url:'http://taruinfo.work:8088/newborn/insert',
	// 		data:data,
	// 		method:'POST',
	// 		success:function(res){
	// 			console.log('调用用户个人信息接口成功：')
	// 			console.log(res.data.message)
	// 		}
	// 	})
	// }
	}
}
</script>

<style scoped>
	.dem_title{
		padding: 0 28rpx;
		padding-top: 12rpx;
		padding-bottom: 38rpx;
		border-bottom: 1rpx solid #e6e6e6;
		font-size: 44rpx;
		font-weight: 900;
		color: #333333;
	}
	.main_view{
		margin-left: 20rpx;
		margin-right: 20rpx;
	}
	.demand{
		box-sizing: border-box;
	}
</style>